<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh-CN"/>

<div class="modal-dialog demo2do-modal-dialog">

  <div class="modal-content">

    <div class="modal-header earth-breadcrumb no-bottom-border clearfix">
      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>服务商&nbsp;-&nbsp;编辑账户信息</span></h2>
      <button type="button" class="close" data-dismiss="modal">&times;</button>
    </div>

    <form id="account-edit-form" class="form-horizontal" method="post" action="${ctx}/apps/${app.id}/account/${account.id}" enctype="multipart/form-data" data-validate="true">
      
      <input type="hidden" name="_method" value="PATCH" >
     
      <input type="hidden" name="id" value="${account.id}" >
      
      <div class="modal-body">

        <div class="form-group demo2do-form-group">
          <label class="col-xs-3 control-label">账户名称</label>
          <div class="col-xs-7">
            <input type="text" class="form-control" name="name" data-validate="required" value="${account.name}">
          </div>
        </div>
        
        <div class="form-group demo2do-form-group">
          <label class="col-xs-3 control-label">Logo</label>
          <div class="col-xs-7">
            <div data-toggle="preupload">
              <input type="file" name="logoImage" class="preupload-file" id="hidden-file-input">
              <input type="hidden" name="logo" value="${account.logo}">
              <div class="earth-pay-card">
                <img src="${ctx.upload}/${account.logo}">
                <div class="card-cover">
                  <a href="javascript: void(0)" class="preupload-relink" data-target="#hidden-file-input" title="上传图标"><i class="glyphicon glyphicon-plus"></i></a>
                </div>
              </div>
            </div>
          </div>
        </div>   
        
        <div class="form-group demo2do-form-group">
          <label class="col-xs-3 control-label">Header</label>
          <div class="col-xs-7">
            <div data-toggle="preupload">
              <input type="file" name="headerImage" class="preupload-file" id="hidden-file-input">
              <input type="hidden" name="header" value="${account.header}">
              <div class="earth-pay-card">
                <img src="${ctx.upload}/${account.header}">  
                <div class="card-cover">                            
                  <a href="javascript: void(0)" class="preupload-relink" data-target="#hidden-file-input" title="上传小图标"><i class="glyphicon glyphicon-plus"></i></a>
                </div>
              </div>
            </div>
          </div>
        </div>        
        		
      </div>

      <div class="modal-footer">
        <button id="submit" type="submit" class="btn btn-success btn-shadow btn-shadow-success demo2do-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" data-dismiss="modal">取消</button>
      </div>

    </form>

  </div>

</div>

<script src="${ctx.resource}/js/bootstrap.validate.trigger.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $('[data-toggle="preupload"]').preupload();
    $('#account-edit-form').submit(function() {
      var isValid = true;
      $(this).find('[data-toggle="preupload"]').each(function() {
        
        if($(this).find('img').length == 0) {
          $(this).append('<p class="no-botto-margin text-danger">请上传图标！</p>');
          isValid = false;
          return false;
        }
      });
      return isValid;
    });
  });
</script>